package com.psp.bu.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.northend.util.AppTextUtil;
import com.northend.util.NumUtil;
import com.northend.util.StringUtil;
import com.psp.bu.cache.dao.ServiceCategoryCacheDao;
import com.psp.bu.controller.res.bean.RAttributeBean;
import com.psp.bu.controller.res.bean.RAttributeValueBean;
import com.psp.bu.controller.res.bean.RProductDetailBean;
import com.psp.bu.controller.res.bean.RProductEditDetailBean;
import com.psp.bu.controller.res.bean.RProductListBean;
import com.psp.bu.controller.res.bean.RProductSkuBean;
import com.psp.bu.controller.res.bean.RServicesTypeBean;
import com.psp.bu.model.CategoryProductRelationBean;
import com.psp.bu.model.ProductAttributeBean;
import com.psp.bu.model.ProductAttributeRelationBean;
import com.psp.bu.model.ProductBean;
import com.psp.bu.model.ProductEditInfoBean;
import com.psp.bu.model.ProductSkuBean;
import com.psp.bu.model.ProductUpdateLogBean;
import com.psp.bu.model.ServiceCategoryBean;
import com.psp.bu.model.UserBean;
import com.psp.bu.model.UserProductRelationBean;
import com.psp.bu.persist.dao.ProductAttributeDao;
import com.psp.bu.persist.dao.ProductDao;
import com.psp.bu.persist.dao.ServiceCategoryDao;
import com.psp.bu.persist.dao.UserDao;
import com.psp.bu.service.ProductService;
import com.psp.bu.service.exception.ServiceException;

@Service
public class ProductServiceImpl implements ProductService {

	@Autowired
	ProductDao productImpl;

	@Autowired
	UserDao userImpl;

	@Autowired
	ProductAttributeDao productAttributeImpl;

	@Autowired
	ServiceCategoryDao serviceCategoryImpl;

	@Autowired
	ServiceCategoryCacheDao serviceCategoryCacheImpl;
	
	

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean onShelfBatch(String buid, List<String> list) throws ServiceException {
		boolean flag = false;
		if (StringUtil.isEmpty(buid)) {
			throw new ServiceException("object_is_not_exist", "用户");
		}
		// 查出业务组含有的那些 服务
		List<ProductBean> pidList = productImpl.selectByBuidAndList(buid, list);
		if (pidList == null || pidList.size() <= 0) {
			throw new ServiceException("object_is_not_exist", "业务组的服务");
		}

		// 过滤出pid
		List<String> operList = new ArrayList<>();
		for (ProductBean bean : pidList) {
			operList.add(bean.getPid());
		}

		if (operList != null && operList.size() > 0) {
			// 上架
			flag = productImpl.updateStateBatch(operList, 1) > 0;
		}
		return flag;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean offShelfBatch(String buid, List<String> list) throws ServiceException {
		boolean flag = false;
		if (StringUtil.isEmpty(buid)) {
			throw new ServiceException("object_is_not_exist", "用户");
		}
		// 查出业务组含有的那些 服务
		List<ProductBean> pidList = productImpl.selectByBuidAndList(buid, list);
		if (pidList == null || pidList.size() <= 0) {
			throw new ServiceException("object_is_not_exist", "业务组的服务");
		}
		// 过滤出pid
		List<String> operList = new ArrayList<>();
		for (ProductBean bean : pidList) {
			operList.add(bean.getPid());
		}
		if (operList != null && operList.size() > 0) {
			// 下架
			flag = productImpl.updateStateBatch(operList, 2) > 0;
		}
		return flag;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean deleteBatch(String buid, List<String> list) throws ServiceException {
		boolean flag = false;
		if (StringUtil.isEmpty(buid)) {
			throw new ServiceException("object_is_not_exist", "用户");
		}
		// 查出业务组含有的那些 服务
		List<ProductBean> pidList = productImpl.selectByBuidAndList(buid, list);
		if (pidList == null || pidList.size() <= 0) {
			throw new ServiceException("object_is_not_exist", "业务组的服务");
		}
		// 过滤出pid
		List<String> operList = new ArrayList<>();
		for (ProductBean bean : pidList) {
			operList.add(bean.getPid());
		}
		if (operList != null && operList.size() > 0) {
			flag = productImpl.updateIsDeleteBatch(operList, 2) > 0;
			// flag = productImpl.deleteUserProductRelationBatch(buid, operList)
			// > 0; TODO 先不删除业务员 和产品之间的关系
		}

		return flag;
	}

	/**
	 * 商品保存
	 */
	@Transactional(rollbackFor = Exception.class)

	@Override
	public boolean save(String userId, int category, int type, String title, String subTitle, String img, int quoteType,
			double price, String serviceContent, String serviceSafe, String linkMan, String telephone,
			String attributeJson, String attributeArr, String attributeValueArr, int hasInvocie)
			throws ServiceException {
		ProductBean product = new ProductBean();
		String pid = AppTextUtil.getPrimaryKey();
		product.setPid(pid);
		product.setTypeCode(category);
		product.setType(type);
		product.setTitle(title);
		product.setSubTitle(subTitle);
		product.setImg(img);
		product.setQuoteType(quoteType);
		product.setPrice(price);
		product.setServiceContent(serviceContent);
		product.setServiceSafe(serviceSafe);
		product.setLinkMan(linkMan);
		product.setTelephone(telephone);
		product.setState(1);// 状态为在售
		product.setHasInvoice(hasInvocie);

		JSONArray attrArray = JSON.parseArray(attributeArr);
		JSONArray attrValueArray = JSON.parseArray(attributeValueArr);

		List<ProductAttributeBean> attrs = new ArrayList<>();
		List<ProductAttributeRelationBean> relations = new ArrayList<>();
		// 定义属性
		if (attrArray != null && attrArray.size() > 0) {
			for (int i = 0; i < attrArray.size(); i++) {
				String aid = AppTextUtil.getPrimaryKey();
				String name = (String) attrArray.get(i);
				ProductAttributeBean attr = new ProductAttributeBean();
				ProductAttributeRelationBean rale = new ProductAttributeRelationBean();
				attr.setName(name);
				attr.setAid(aid);
				attr.setType(2);// 自定义属性
				attrs.add(attr);
				rale.setRid(AppTextUtil.getPrimaryKey());
				rale.setPid(pid);
				rale.setAid(aid);
				relations.add(rale);
			}
		}
		boolean flag = productImpl.insert(product) > 0;// 产品基本信息表
		if (flag) {
			product = productImpl.selectById(pid);
			UserProductRelationBean userproduct = new UserProductRelationBean();
			userproduct.setRid(AppTextUtil.getPrimaryKey());
			userproduct.setPid(pid);
			userproduct.setBuid(userId);
			// 插入服务-用户关系表 user_product_relation
			flag = productImpl.insertUserProduct(userproduct) > 0;// 用户产品关系表
			if (flag) {
				CategoryProductRelationBean cateproduct = new CategoryProductRelationBean();
				cateproduct.setCid(AppTextUtil.getPrimaryKey());
				cateproduct.setPid(pid);
				cateproduct.setCateCode(category);

				// 插入属性-分类关系表 category_product_relation
				flag = productAttributeImpl.insertCateProductRelation(cateproduct) > 0;// 分类属性关系表
				if (!flag) {
					throw new ServiceException("pro_cate_relation_insert_error");
				}
			}
		} else {
			throw new ServiceException("product_insert_error");
		}
		if (attrs.size() > 0) {
			// 插入属性表 product_attribute
			flag = productAttributeImpl.insertList(attrs) > 0;
			if (!flag) {
				throw new ServiceException("attribute_insert_error");
			}
			// 插入服务-属性关系表 product_attribute_ralation
			flag = productAttributeImpl.insertProAttriRelation(relations) > 0;// 服务属性关系表
			if (!flag) {
				throw new ServiceException("pro_attri_relation_insert_error");
			}
			//

			// 获取产品已定义的属性(获取属性code)
			List<ProductAttributeBean> newAttributes = productAttributeImpl.selectListByPid(pid);
			if (newAttributes.size() > 0) {
				for (int i = 0; i < newAttributes.size(); i++) {
					ProductAttributeBean pa = newAttributes.get(i);
					JSONArray jobj = (JSONArray) attrValueArray.get(i);// skuvalues
					String aname = "";
					int acode = 0;
					JSONArray aJsonValus = new JSONArray();
					for (int j = 0; j < jobj.size(); j++) {
						JSONObject ajson = new JSONObject();
						aname = jobj.get(j).toString();
						acode++;
						ajson.put("name", aname);
						ajson.put("code", acode);
						aJsonValus.add(ajson);
					}
					pa.setValue(aJsonValus.toJSONString());
				}
				int rownums = 1;
				int attriNum = newAttributes.size();
				for (ProductAttributeBean b : newAttributes) {
					JSONArray aJsonValus = JSONArray.parseArray(b.getValue());
					rownums = rownums * aJsonValus.size();
				}
				//
				List<ProductSkuBean> skus = new ArrayList<>();
				JSONArray tableJson = JSONArray.parseArray(attributeJson);
				for (int r = 0; r < rownums; r++) {
					int plen = 1;
					ProductSkuBean sku = new ProductSkuBean();
					sku.setSkuId(AppTextUtil.getPrimaryKey());
					sku.setPid(pid);
					StringBuffer skuNo = new StringBuffer("p" + product.getPcode());
					skuNo.append("a");
					JSONArray skuArrjson = new JSONArray();
					for (int a = 0; a < attriNum; a++) {
						JSONArray skutable = tableJson.getJSONArray(r);
						JSONObject skujson = new JSONObject();
						ProductAttributeBean attribute = newAttributes.get(a);
						Integer acode = attribute.getAcode();
						skuNo.append(acode);
						JSONArray aJsonValus = JSONArray.parseArray(attribute.getValue());
						int len = aJsonValus.size();
						plen = plen * len;
						int crows = rownums / plen;
						int index = (r / crows) % len;
						// 属性值赋值
						JSONObject value = (JSONObject) aJsonValus.get(index);
						skuNo.append(value.get("code"));
						skujson.put("acode", acode);
						skujson.put("value", value.get("code"));

						// 价格数量赋值
						JSONObject priceobj = (JSONObject) skutable.get(skutable.size() - 2);
						JSONObject numobj = (JSONObject) skutable.get(skutable.size() - 1);
						sku.setPrice(NumUtil.toDouble(priceobj.get("value"), 0));
						sku.setNum(NumUtil.toInt(numobj.get("value"), 0));
						sku.setSkuCode(skuNo.toString());
						skuArrjson.add(skujson);
					}
					sku.setSkuJson(skuArrjson.toJSONString());
					skus.add(sku);
				}

				// 1更新属性报表
				flag = productAttributeImpl.updateList(newAttributes) > 0;
				if (!flag) {
					throw new ServiceException("attribute_update_error");
				} // TODO:更新日志
					// 2插入sku表 product_sku
				flag = productAttributeImpl.insertProductSkuList(skus) > 0;
				if (!flag) {
					throw new ServiceException("sku_insert_error");
				}
				// 3插入编辑信息：商品属性名，商品属性值，sku整个数组
				ProductEditInfoBean eidtInfo = new ProductEditInfoBean();
				eidtInfo.setPcode(product.getPcode());
				eidtInfo.setAttributeArr(attributeArr);
				eidtInfo.setAttributeValueArr(attributeValueArr);
				eidtInfo.setAttributeJson(attributeJson);
				flag = productImpl.inserProductEditInfo(eidtInfo) > 0;
				if (!flag) {
					throw new ServiceException("prodcut_edit_insert_error");
				}

				// 清空缓存
				serviceCategoryCacheImpl.clearWebServiceCache();
			}

		}

		return flag;
	}

	@Transactional(rollbackFor = Exception.class)
	@Override
	public boolean update(String userId, int category, int type, String title, String subTitle, String img,
			int quoteType, double price, String serviceContent, String serviceSafe, String linkMan, String telephone,
			String attributeJson, String attributeArr, String attributeValueArr, int hasInvocie, String bid)
			throws ServiceException {
		ProductUpdateLogBean update = new ProductUpdateLogBean();
		ProductBean product = productImpl.selectById(bid);
		update.setOldData(JSON.toJSONString(product));
		if (product == null) {
			throw new ServiceException("object_is_not_exist", "商品");
		}
		product.setTypeCode(category);
		product.setType(type);
		product.setTitle(title);
		product.setSubTitle(subTitle);
		product.setImg(img);
		product.setQuoteType(quoteType);
		product.setPrice(price);
		product.setServiceContent(serviceContent);
		product.setServiceSafe(serviceSafe);
		product.setLinkMan(linkMan);
		product.setTelephone(telephone);
		// product.setState(1);// 修改是不改状态
		product.setHasInvoice(hasInvocie);

		// 更新历史属性和历史sku的状态
		boolean flag = productAttributeImpl.updateProAttributes(product.getPid(), 1) > 0;// 1删除状态
		if (flag) {
			flag = productAttributeImpl.updateProSkus(product.getPid(), 1) > 0;// 1删除状态
		}

		JSONArray attrArray = JSON.parseArray(attributeArr);
		JSONArray attrValueArray = JSON.parseArray(attributeValueArr);

		// 设置新定义的属性值和sku
		List<ProductAttributeBean> attrs = new ArrayList<>();
		List<ProductAttributeRelationBean> relations = new ArrayList<>();
		// 定义属性
		if (attrArray != null && attrArray.size() > 0) {
			for (int i = 0; i < attrArray.size(); i++) {
				String aid = AppTextUtil.getPrimaryKey();
				String name = (String) attrArray.get(i);
				ProductAttributeBean attr = new ProductAttributeBean();
				ProductAttributeRelationBean rale = new ProductAttributeRelationBean();
				attr.setName(name);
				attr.setAid(aid);
				attr.setType(2);// 自定义属性
				attrs.add(attr);
				rale.setRid(AppTextUtil.getPrimaryKey());
				rale.setPid(product.getPid());
				rale.setAid(aid);
				relations.add(rale);
			}
		}
		flag = productImpl.update(product) > 0;// 产品基本信息表
		if (flag) {
			product = productImpl.selectById(product.getPid());
		} else {
			throw new ServiceException("product_insert_error");
		}
		if (attrs.size() > 0) {
			// 插入属性表 product_attribute
			flag = productAttributeImpl.insertList(attrs) > 0;
			if (!flag) {
				throw new ServiceException("attribute_insert_error");
			}
			// 插入服务-属性关系表 product_attribute_ralation
			flag = productAttributeImpl.insertProAttriRelation(relations) > 0;// 服务属性关系表
			if (!flag) {
				throw new ServiceException("pro_attri_relation_insert_error");
			}
			//

			// 获取产品已定义的属性(获取属性code)
			List<ProductAttributeBean> newAttributes = productAttributeImpl.selectListByPid(product.getPid());
			if (newAttributes.size() > 0) {
				for (int i = 0; i < newAttributes.size(); i++) {
					ProductAttributeBean pa = newAttributes.get(i);
					JSONArray jobj = (JSONArray) attrValueArray.get(i);// skuvalues
					String aname = "";
					int acode = 0;
					JSONArray aJsonValus = new JSONArray();
					for (int j = 0; j < jobj.size(); j++) {
						JSONObject ajson = new JSONObject();
						aname = jobj.get(j).toString();
						acode++;
						ajson.put("name", aname);
						ajson.put("code", acode);
						aJsonValus.add(ajson);
					}
					pa.setValue(aJsonValus.toJSONString());
				}
				int rownums = 1;
				int attriNum = newAttributes.size();
				for (ProductAttributeBean b : newAttributes) {
					JSONArray aJsonValus = JSONArray.parseArray(b.getValue());
					rownums = rownums * aJsonValus.size();
				}
				//
				List<ProductSkuBean> skus = new ArrayList<>();
				JSONArray tableJson = JSONArray.parseArray(attributeJson);
				for (int r = 0; r < rownums; r++) {
					int plen = 1;
					ProductSkuBean sku = new ProductSkuBean();
					sku.setSkuId(AppTextUtil.getPrimaryKey());
					sku.setPid(product.getPid());
					StringBuffer skuNo = new StringBuffer("p" + product.getPcode());
					skuNo.append("a");
					JSONArray skuArrjson = new JSONArray();
					for (int a = 0; a < attriNum; a++) {
						JSONArray skutable = tableJson.getJSONArray(r);
						JSONObject skujson = new JSONObject();
						ProductAttributeBean attribute = newAttributes.get(a);
						Integer acode = attribute.getAcode();
						skuNo.append(acode);
						JSONArray aJsonValus = JSONArray.parseArray(attribute.getValue());
						int len = aJsonValus.size();
						plen = plen * len;
						int crows = rownums / plen;
						int index = (r / crows) % len;
						// 属性值赋值
						JSONObject value = (JSONObject) aJsonValus.get(index);
						skuNo.append(value.get("code"));
						skujson.put("acode", acode);
						skujson.put("value", value.get("code"));

						// 价格数量赋值
						JSONObject priceobj = (JSONObject) skutable.get(skutable.size() - 2);
						JSONObject numobj = (JSONObject) skutable.get(skutable.size() - 1);
						sku.setPrice(NumUtil.toDouble(priceobj.get("value"), 0));
						sku.setNum(NumUtil.toInt(numobj.get("value"), 0));
						sku.setSkuCode(skuNo.toString());
						skuArrjson.add(skujson);
					}
					sku.setSkuJson(skuArrjson.toJSONString());
					skus.add(sku);
				}

				// 1更新属性报表
				flag = productAttributeImpl.updateList(newAttributes) > 0;
				if (!flag) {
					throw new ServiceException("attribute_update_error");
				}
				// 2插入sku表 product_sku
				flag = productAttributeImpl.insertProductSkuList(skus) > 0;
				if (!flag) {
					throw new ServiceException("sku_insert_error");
				}
				// 3 更新编辑信息：商品属性名，商品属性值，sku整个数组
				ProductEditInfoBean eidtInfo = new ProductEditInfoBean();
				eidtInfo.setPcode(product.getPcode());
				eidtInfo.setAttributeArr(attributeArr);
				eidtInfo.setAttributeValueArr(attributeValueArr);
				eidtInfo.setAttributeJson(attributeJson);
				flag = productImpl.updateProductEditInfo(eidtInfo) > 0;
				if (!flag) {
					throw new ServiceException("prodcut_edit_insert_error");
				}
				// TODO:更新日志
				update.setNewData(JSON.toJSONString(product));
				update.setPid(product.getPid());
				flag = productImpl.insertUpdateLog(update) > 0;
				
				// 清空缓存
				serviceCategoryCacheImpl.clearWebServiceCache();
			}
		}

		return flag;
	}

	@Override
	public RProductDetailBean getProductDetail(String buid, String pid) {
		RProductDetailBean result = new RProductDetailBean();

		ProductBean product = productImpl.selectById(pid);
		if (product == null) {
			throw new ServiceException("object_is_not_exist", "商品");
		}
		result.setPcode(product.getPcode());
		result.setPid(pid);
		result.setTitle(product.getTitle());
		result.setSubTitle(product.getSubTitle());
		result.setType(product.getType());
		result.setImg(product.getImg());
		result.setServiceContent(product.getServiceContent());
		result.setServiceSafe(product.getServiceSafe());
		result.setPrice(product.getPrice());
		result.setQuoteType(product.getQuoteType());
		result.setLinkMan(product.getLinkMan());
		// TODO:服务范围
		// result.setSArea(product.getarae);
		result.setTelephone(product.getTelephone());
		result.setHasInvoice(product.getHasInvoice() == 1 ? true : false);
		return result;
	}

	@Override
	public RProductEditDetailBean getProductDetailDetail(String buid, String pid) throws ServiceException {
		RProductEditDetailBean result = new RProductEditDetailBean();
		ProductBean product = productImpl.selectById(pid);
		if (product == null) {
			throw new ServiceException("object_is_not_exist", "商品");
		}
		ProductEditInfoBean editInfo = productImpl.selectEditInfoByCode(product.getPcode());

		result.setPid(pid);
		result.setImg(product.getImg());
		result.setSubTitle(product.getSubTitle());
		result.setType(product.getType() + "");
		result.setTitle(product.getTitle());
		result.setLinkMan(product.getLinkMan());
		result.setPrice(product.getPrice());
		// TODO:服务范围
		// result.setSArea(product.getarae);
		result.setServiceContent(product.getServiceContent());
		result.setServiceSafe(product.getServiceSafe());
		result.setTelephone(product.getTelephone());
		result.setQuoteType(product.getQuoteType() + "");
		result.setTypeCode(product.getTypeCode() + "");//
		result.setParentCode(product.getParentCode());

		if (editInfo != null) {
			result.setAttributeArr(editInfo.getAttributeArr());
			result.setAttributeJson(editInfo.getAttributeJson());
			result.setAttributeValueArr(editInfo.getAttributeValueArr());
		}

		return result;
	}

	@Override
	public PageResult<RProductListBean> getList(int page, int pageSize, String buid, int shelfState) {
		PageResult<RProductListBean> result = new PageResult<>();
		UserBean user = userImpl.selectOne(buid);
		if(user.getCateCode() == 99) {
			buid = null;// 查询所有分类
		}
		int count = productImpl.selectProductCount(buid, shelfState);
		
		List<ProductBean> resList = productImpl.selectProductList(page, pageSize, buid, shelfState);

		List<RProductListBean> list = new ArrayList<>();
		if (resList != null && resList.size() > 0) {
			for (ProductBean bean : resList) {
				RProductListBean rb = new RProductListBean();
				rb.setPid(bean.getPid());
				rb.setPcode(String.valueOf(bean.getPcode()));
				rb.setImg(bean.getImg());
				rb.setTitle(bean.getTitle());
				rb.setPrice(bean.getPrice());
				rb.setSellNum(0);// TODO 商品交易量
				rb.setType(bean.getType());
				rb.setQuoteType(bean.getQuoteType());
				rb.setShelfState(bean.getState() == 1 ? true : false);
				rb.setOnShelfDate(
						bean.getOnShelfDate() != null ? bean.getOnShelfDate().getTime() : new Date().getTime());
				rb.setOffShelfDate(
						bean.getOffShelfDate() != null ? bean.getOffShelfDate().getTime() : new Date().getTime());
				list.add(rb);
			}
		}
		result.setCount(count);
		result.setData(list);
		return result;
	}

	@Override
	public RServicesTypeBean getSubServiceTypes(int pcode) {
		RServicesTypeBean bean = new RServicesTypeBean();
		JSONArray jsonArray = new JSONArray();
		String jsonStr = serviceCategoryCacheImpl.getServiceCatesByPcode(pcode);
		if (StringUtil.isEmpty(jsonStr)) {
			List<ServiceCategoryBean> allCates = serviceCategoryImpl.selectTypesByPcode(pcode);
			if (allCates != null && allCates.size() > 0) {
				for (ServiceCategoryBean c : allCates) {
					JSONObject subObject = new JSONObject();
					subObject.put("name", c.getName());
					subObject.put("code", c.getCode());
					jsonArray.add(subObject);
				}
				serviceCategoryCacheImpl.setServiceCatesByPcode(pcode, jsonArray.toJSONString());
			}
		} else {
			jsonArray = JSON.parseArray(jsonStr);
		}
		bean.setServiceType(jsonArray);//
		return bean;
	}

	@Override
	public List<RAttributeBean> getAttributes(String pid) {
		List<RAttributeBean> result = new ArrayList<>();
		List<ProductAttributeBean> attributes = productImpl.selectAttributeList(pid);
		if (attributes.size() > 0) {
			for (ProductAttributeBean a : attributes) {
				RAttributeBean ra = new RAttributeBean();
				ra.setAcode(a.getAcode());
				ra.setAid(a.getAid());
				ra.setName(a.getName());
				List<RAttributeValueBean> values = JSONArray.parseArray(a.getValue(), RAttributeValueBean.class);
				int i = 0;
				for (RAttributeValueBean v : values) {
					v.setSelected(i++ == 0 ? 1 : 0);
				}
				ra.setValue(values);
				result.add(ra);
			}
		}
		return result;
	}

	@Override
	public RProductSkuBean getProductInfoBySkuno(String skuCode) {
		RProductSkuBean res = null;
		ProductSkuBean skuBean = productImpl.selectProductInfoBySukCode(skuCode, 0);
		if (skuBean != null) {
			res = new RProductSkuBean();
			res.setNum(skuBean.getNum());
			res.setPrice(skuBean.getPrice());
			res.setSkuId(skuBean.getSkuId());
			res.setSkuJson(skuBean.getSkuJson());
			res.setPid(skuBean.getPid());
		}
		return res;
	}

}
